/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CustomerInfo;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ShowAppCustomerDetail extends AbstractAction
/*    */ {
/* 26 */   private static Logger logger = Logger.getLogger(ShowAppCustomerDetail.class
/* 27 */     .getName());
/*    */ 
/*    */   public ShowAppCustomerDetail(AbstractHttpServlet servlet)
/*    */   {
/* 30 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 37 */     response.setContentType("text/html;charset=utf-8");
/* 38 */     PrintWriter out = response.getWriter();
/* 39 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 41 */     int id = Util.getURLIntParameter(request.getParameter("customerId"));
/* 42 */     CustomerManager manager = new CustomerManager();
/*    */     try {
/* 44 */       CustomerInfo customerInfo = manager.getCustomerInfo(id, true, true);
/* 45 */       User user = super.getLoginUser(request);
/*    */ 
/* 47 */       if (!customerInfo.hasViewRight(user, 
/* 47 */         super.getCompany(user.companyId))) {
/* 48 */         showErrorMessage(response, "您没有查看该客户的权限");
/* 49 */         return;
/*    */       }
/*    */ 
/* 52 */       String ip = Util.getClientIpAddr(request);
/* 53 */       logger.warn("ip:" + ip + " / 用户Id：" + user.userId + " /  用户名：" + 
/* 54 */         user.name + ", 浏览了公司：id:  " + customerInfo.id + " / 名称：" + 
/* 55 */         customerInfo.name);
/*    */ 
/* 57 */       jsonObject.put("error", "0");
/* 58 */       jsonObject.put("customerInfo", customerInfo);
/*    */     } catch (DBException e) {
/* 60 */       logger.warn("get customer info failed", e);
/* 61 */       jsonObject.put("error", "1");
/* 62 */       jsonObject.put("msg", "获得客户详细信息失败");
/*    */     }
/* 64 */     out.println(jsonObject);
/* 65 */     out.flush();
/* 66 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ShowAppCustomerDetail
 * JD-Core Version:    0.6.1
 */